import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-03-03
 * Time: 19:23
 */
public class Test {

    //幸运数字
    public static void main1(String[] args) {
        int i = 1;
        int count = 0;
        while(true) {
            if(i % get_n(i,2) == 0 && i % get_n(i,8) == 0 && i % get_n(i,10) == 0 && i % get_n(i,16) == 0) {
                count++;
            }
            if(count == 2023) {
                break;
            }
            i++;
        }
        System.out.println(i);
    }

    public static int get_n(int n, int binary) {
        int sum = 0;
        while(n > 0) {
            sum += n % binary;
            n /= binary;
        }
        return sum;
    }

        //阶乘
        public static long INF = 10000000000L;

        //420940313
        public static void main(String[] args) {
            long sum = 0;
            for(int i  = 1; i <= 40; i++) {
                sum += fact(i);
            }
            System.out.println(sum % 1000000000);
        }

        public static long fact(int n) {
           long sum1 = 1;
           for(int i = 1; i <= n; i++) {
               sum1 *= i;
               if(sum1 >= INF) {
                   sum1 %= INF;
               }
           }
           return sum1;
        }
}

